package com.yuyou.fn.educational.mapper;

import com.github.wens.mybatisplus.mapper.AutoMapper;
import com.yuyou.fn.educational.entity.TeacherContinueClassStat;
import com.yuyou.fn.educational.vo.RankByContinueClassVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 * TeacherContinueClassStat 表数据库控制层接口
 *
 */
public interface TeacherContinueClassStatMapper extends AutoMapper<TeacherContinueClassStat,Long> {


    @Select("select (@rank:=@rank+1 ) as rankNo , continue_class_amount/a.total_amount as rate , a.teacher_id teacherId   from teacher_continue_class_stat a , (select @rank :=0)  b where a.area_team_id = #{areaTeamId} and a.period_id = #{periodId} order by rate desc")
    List<RankByContinueClassVo> rank(@Param("areaTeamId") Long areaTeamId, @Param("periodId") Long periodId);

    @Select("select c.* from (select (@rank:=@rank+1 ) rankNo , continue_class_amount/a.total_amount as rate , a.teacher_id teacherId   from teacher_continue_class_stat a , (select @rank :=0)  b  where a.area_team_id = #{areaTeamId} and a.period_id = #{periodId} order by rate desc ) c where teacherId = #{teacherId} ")
    RankByContinueClassVo myRank(@Param("areaTeamId") Long areaTeamId, @Param("periodId") Long periodId, @Param("teacherId") Long teacherId);

}